/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package am.aua.renju.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Ara Yeritsian
 */
@Entity
@Table(name = "move_history")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MoveHistory.findAll", query = "SELECT m FROM MoveHistory m"),
    @NamedQuery(name = "MoveHistory.findById", query = "SELECT m FROM MoveHistory m WHERE m.id = :id"),
    @NamedQuery(name = "MoveHistory.findByTurn", query = "SELECT m FROM MoveHistory m WHERE m.turn = :turn"),
    @NamedQuery(name = "MoveHistory.findByPos", query = "SELECT m FROM MoveHistory m WHERE m.pos = :pos"),
    @NamedQuery(name = "MoveHistory.findByTime", query = "SELECT m FROM MoveHistory m WHERE m.time = :time")})
public class MoveHistory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "turn")
    private int turn;
    @Basic(optional = false)
    @NotNull
    @Column(name = "pos")
    private int pos;
    @Column(name = "time")
    private Integer time;
    @JoinColumn(name = "player_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Player playerId;
    @JoinColumn(name = "game_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Game gameId;

    public MoveHistory() {
    }

    public MoveHistory(Integer id) {
        this.id = id;
    }

    public MoveHistory(Integer id, int turn, int pos) {
        this.id = id;
        this.turn = turn;
        this.pos = pos;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public int getTurn() {
        return turn;
    }

    public void setTurn(int turn) {
        this.turn = turn;
    }

    public int getPos() {
        return pos;
    }

    public void setPos(int pos) {
        this.pos = pos;
    }

    public Integer getTime() {
        return time;
    }

    public void setTime(Integer time) {
        this.time = time;
    }

    public Player getPlayerId() {
        return playerId;
    }

    public void setPlayerId(Player playerId) {
        this.playerId = playerId;
    }

    public Game getGameId() {
        return gameId;
    }

    public void setGameId(Game gameId) {
        this.gameId = gameId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MoveHistory)) {
            return false;
        }
        MoveHistory other = (MoveHistory) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "am.aua.renju.entity.MoveHistory[ id=" + id + " ]";
    }
    
}
